package co.com.tigo.crm.v1.portalcrmservice.builder;

import java.util.ArrayList;
import java.util.List;

import co.com.colombiamovil.gatewayservice.facade.dto.EnableDesableAvailableServiceInput;
import co.com.colombiamovil.gatewayservice.facade.dto.EnableDisableElectronicInvoiceInput;
import co.com.colombiamovil.gatewayservice.facade.dto.ServicesEnableDisableInput;
import co.com.tigo.xmlns.crm.AvailableServices;
import co.com.tigo.xmlns.crm.EnableDisableAvailableServiceResquest;
import co.com.tigo.xmlns.crm.EnableDisableElectronicInvoice;

public class DTOBuilder {

	public static ServicesEnableDisableInput toServicesEnableDisableInput(AvailableServices availableServicesRequest) {
		ServicesEnableDisableInput servicesEnableDisableInput = new ServicesEnableDisableInput();
		servicesEnableDisableInput.setMsisdn(availableServicesRequest.getMsisdn());
		return servicesEnableDisableInput;
	}

	public static EnableDesableAvailableServiceInput toEnableDisableAvailableServiceInput(
			EnableDisableAvailableServiceResquest enableDisableAvailableServiceRequest) {
		EnableDesableAvailableServiceInput enableDisableAvailableServiceInput = new EnableDesableAvailableServiceInput();
         enableDisableAvailableServiceInput.setMsisdn(enableDisableAvailableServiceRequest.getMsisdn());
		if(enableDisableAvailableServiceRequest.getOperation() != null){
			enableDisableAvailableServiceInput.setOperation(enableDisableAvailableServiceRequest.getOperation().toString() );
		}
		enableDisableAvailableServiceInput.setServiceId(enableDisableAvailableServiceRequest.getServiceId());
		List<co.com.tigo.xmlns.crm.ParamDTO> paramListRequest = enableDisableAvailableServiceRequest.getParamsList();
		ArrayList<co.com.colombiamovil.gatewayservice.facade.dto.ParamDTO> paramList = new java.util.ArrayList<co.com.colombiamovil.gatewayservice.facade.dto.ParamDTO>();

		for (co.com.tigo.xmlns.crm.ParamDTO paramDTORequest : paramListRequest) {
			co.com.colombiamovil.gatewayservice.facade.dto.ParamDTO paramDTOInput = new co.com.colombiamovil.gatewayservice.facade.dto.ParamDTO();
			paramDTOInput.setName(paramDTORequest.getName());
			paramDTOInput.setType(paramDTORequest.getType());
			paramDTOInput.setValue(paramDTORequest.getValue());
			paramList.add(paramDTOInput);
		}
		enableDisableAvailableServiceInput.setParamsList(paramList);
		return enableDisableAvailableServiceInput;
	}

	public static EnableDisableElectronicInvoiceInput toEnableDisableElectronicInvoiceInput(
			EnableDisableElectronicInvoice enableDisableElectronicInvoiceRequest) {
		EnableDisableElectronicInvoiceInput electronicInvoiceInput = new EnableDisableElectronicInvoiceInput();
		electronicInvoiceInput.setMsisdn(enableDisableElectronicInvoiceRequest.getMsisdn());
		if(enableDisableElectronicInvoiceRequest.getSummaryOption() != null){
			electronicInvoiceInput.setSummaryOption(EnableDisableElectronicInvoiceInput.SUMMARY_OPTION
				.valueOf(enableDisableElectronicInvoiceRequest.getSummaryOption().value()));
		}
		electronicInvoiceInput.setInvoiceOption(EnableDisableElectronicInvoiceInput.INVOICE_OPTION
				.valueOfbyId(enableDisableElectronicInvoiceRequest.getInvoiceOption()));
		return electronicInvoiceInput;
	}

}
